@extends('admin.frame_layout')
<?php $top_selected = "系统设置";$page_menu = "一键初始化" ?>

@section('content')
    <div class="formbody">
        <div class="formtitle"><span>一键初始化</span></div>
        <form action="{{route('admin.initial.act')}}" method="post" id="initial">
            {!! csrf_field() !!}
            <ul class="forminfo">
                {!! inputText("根节点用户名",
                    "username","text","") !!}
                {!! inputText("根节点密码",
                                    "userpass","password","") !!}
                {!! inputText("管理员密码",
                                    "adminpass","password","") !!}
                <li>
                    <label class="lable">&nbsp;</label>
                    <input type="submit" class="btn" value="一键初始化" style="margin-top:10px;"/>
                </li>
            </ul>
        </form>
    </div>
@endsection

@section('footer')
    <script type="text/javascript">
        $("#initial").validate({
            rules: {
                username: {
                    required: true,
                    maxlength: 30
                },
                userpass: {
                    required: true,
                    maxlength: 30
                },
                adminpass: {
                    required: true,
                    maxlength: 30
                },
            }, errorPlacement: function (error, element) {
                $(element).closest("form").find("i[for='" + element.attr("id") + "']").html(error);
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    dataType: "json",
                    type: "post",
                    success: function (data) {
                        if (data.code == 0) {
                            toastr["success"](data.msg);
                            setInterval(function () {
                                window.location = "{{route('admin.initial')}}";
                            }, 2000);
                        } else {
                            toastr["error"](data.msg);
                        }
                    }
                });
            }
        });
    </script>
@endsection
